package cn.itcast.controller;

import cn.itcast.entity.Result;
import cn.itcast.service.MemberService;
import com.alibaba.dubbo.config.annotation.Reference;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

@RestController
@RequestMapping("/member")
@Slf4j
public class MemberController {

    @Reference
    private MemberService memberService;

    /**
     * 用户登录
     * @param param
     * @return
     */
    @PostMapping("/login")
        public ResponseEntity<Result> logIn(@RequestBody Map<String,String> param){

            String phone = param.get("phone");

            String validateCode = param.get("validateCode");

            Result result = null;
            try {
                result = memberService.logIn(phone,validateCode);
            } catch (Exception e) {
                log.error("登录失败!");
            }

            return ResponseEntity.ok(result);
        }
}
